$(function () {
    load();
})

function fh() {
    localStorage.removeItem("mdesignprocedureUP");
    location.href = "../../li_meng/mdesignprocedureUP.html";
}

let wuXJ = [];
let zong = 0;
function load() {
    let mdesignprocedureUP=JSON.parse(localStorage.getItem("mdesignprocedureUP"));
    $("#rname").val(mdesignprocedureUP.checker);
    $("#date").val(mdesignprocedureUP.checktime);
    $("#register").val(mdesignprocedureUP.register);
    $("#registerTime").val(mdesignprocedureUP.registertime);
    //工序设计单编号
    $("#designid").text(mdesignprocedureUP.designid);
    //设计人
    $("#designer").text(mdesignprocedureUP.designer);
    //产品编号
    $("#productid").text(mdesignprocedureUP.productid);
    //产品名称
    $("#productname").text(mdesignprocedureUP.productname);
    //工时总成本
    $("#costpricesum").text(mdesignprocedureUP.costpricesum);

    //设计要求
    let i=0;
    $("#proceduredescribe").text(mdesignprocedureUP.proceduredescribe);
    $.post("/Mdesignproceduredetails.do/ChaById", {id:mdesignprocedureUP.id}, function (sdata) {
        let str = " <tr >\n" +
            "           <th>序号</th>\n" +
            "           <th>工序名称</th>\n" +
            "           <th>工序编号</th>\n" +
            "           <th>描述</th>\n" +
            "           <th>工时数</th>\n" +
            "           <th>工时成本小计(元)</th>\n" +
            "           <th>物料成本小计(元)</th>\n" +
            "           <th>更改</th>\n" +
            "       </tr>\n";

        $.each(sdata, function (index, item) {
            let s = JSON.stringify(item);
            str +="  <tr>\n" +
                "      <td>" + item.detailsnumber + "</td>\n" +
                "      <td>" + item.procedurename + "</td>\n" +
                "      <td>" + item.procedureid + "</td>\n" +
                "      <td>" + item.proceduredescribe + "</td>\n" +
                "      <td>" + item.costprice + "</td>\n" +
                "      <td>"+(item.subtotal==null?'0.00':item.subtotal)+"</td>\n" +
                "      <td>"+(item.modulesubtotal==null?'0.00':item.modulesubtotal)+"</td>\n" +
                "      <td><button class='designmoduletag' onclick='SheJi("+s+")'>更改</button></td>\n" +
                "  </tr>";
            zong +=item.modulesubtotal==null?0:item.modulesubtotal;
            wuXJ[i]=item.designmoduletag;
            i+=1;
        })
        $("#tableAdd").html(str);
        $("#modulecostpricesum").text(zong);
    })
}

function SheJi(op) {
    localStorage.setItem("mdesignprocedureUP(1)",JSON.stringify(op));
    location.href="../../li_meng/mdesignprocedureUP(1)(01).html";
}

function xx() {
    location.href = "../../li_meng/mdesignprocedureUP(1)(01).html";
}


